package com.a.a;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

class i<T extends h> implements aa {
    private volatile boolean onStartCalled;
    volatile boolean b;
    @Nullable
    protected volatile T c;
    @Nullable
    private final o d;
    @NonNull
    private final o e;

    public i(@Nullable T arg2, @Nullable o arg3, @NonNull o arg4) {
        this.onStartCalled = false;
        this.b = false;
        this.c = arg2;
        this.d = arg3;
        this.e = arg4;
    }

    final void a(@NonNull Runnable arg2) {
        if (this.d != null) {
            this.d.a(arg2);
        } else {
            this.e.a(arg2);
        }
    }

    public final void a(@NonNull Throwable throwable) {
        T v0 = this.c;
        if (v0 != null) {
            this.a(new k(v0, throwable));
        }

        this.b = true;
        this.c = null;
    }

    public final void b() {
        this.c = null;
    }

    public final void onStart() {
        T v0 = this.c;
        if (this.onStartCalled) {
            throw new RuntimeException("onStart is called internally, do not call it yourself");
        }

        if (v0 != null) {
            this.a(new n());
        }

        this.onStartCalled = true;
    }
}

